// ShapePosition.cpp : Implementation of CShapePosition
#include "stdafx.h"
#include "ShapeObjects.h"
#include "ShapePosition.h"
#include "com_fun.h"
/////////////////////////////////////////////////////////////////////////////
// CShapePosition


STDMETHODIMP CShapePosition::VLtoDL(int vl, double *dl)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())

	// TODO: Add your implementation code here
	*dl = ::VLtoDL(vl,&m_ShapePosition);
	return S_OK;
}
STDMETHODIMP CShapePosition::DLtoVL(double dl,int *vl)
{
	*vl = ::DLtoVL(dl,&m_ShapePosition);
	return S_OK;
}

STDMETHODIMP CShapePosition::SetData(long pDataAddr)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())

	// TODO: Add your implementation code here
	ATLASSERT(!IsBadReadPtr((void*)pDataAddr,sizeof(SHAPEPOS)));

	memcpy(&m_ShapePosition,(void*)pDataAddr,sizeof(SHAPEPOS));


	SHAPEPOS *pSP = &m_ShapePosition;
	if(pSP->MapMode==MM_GEOWGS84)
	{
		pSP->ScaleX	= (pSP->dRect.right-pSP->dRect.left)/(pSP->vRect.right-pSP->vRect.left);
		pSP->ScaleY	= (pSP->dRect.top-pSP->dRect.bottom)/(pSP->vRect.bottom-pSP->vRect.top);
	}else if(pSP->MapMode==MM_GEOGAUSS)
	{
		pSP->ScaleX	= (pSP->dRect.top-pSP->dRect.bottom)/(pSP->vRect.bottom-pSP->vRect.top);
		pSP->ScaleY	= (pSP->dRect.right-pSP->dRect.left)/(pSP->vRect.right-pSP->vRect.left);
	}
	return S_OK;
}


STDMETHODIMP CShapePosition::AccessDataAddr(long* pDataAddr)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())

	// TODO: Add your implementation code here
	*pDataAddr =(long) &m_ShapePosition;
	return S_OK;
}
